#ifndef GAME_H
#define GAME_H

#include <string>

#include "SFML/Graphics.hpp"

#include "AnimatedSprite.h"
#include "Enemy.h"
#include "EnemyManager.h"
#include "Named.h"
#include "Player.h"
#include "PlayerController.h"
#include "Inventory.h"
#include "Camera.h"

//Forward declarations here

// Represents a loadable/savable game.
class Game 
: public Named
{
public:
	Game();
	virtual ~Game();
	
    // Returns true if the game is being played and can be rendered/updated, etc.
    bool isActive() const;
    void setActive(bool active);

    bool isPaused() const;
    void setPaused(bool paused);

    // Exits current game, clearing all game-related data
    // and re-initializing managers, etc. ready for a game to be loaded.
    // E.g. isActive() will return false after this is called.
    void reset();

    // Creates a new game, storing contents in Saves/game_name.
    // defaultGameName is the name of the default game to base new game's contents on.
    void newGame(const std::string& defaultGameName, const std::string& gameName);
    void loadGame(const std::string& gameName);

    // Saves the current game to gameName.
    void saveGame(const std::string& gameName);

    // deletes the active game.
    void deleteActiveGame();

    // deletes the game at game_name if any.
    // Returns false if couldn't delete.
    // If throwOnFail is true, will throw with description of error on failure to delete.
    static bool deleteGame(const std::string& gameName, bool throwOnFail = false);
    
    void setWindow(sf::RenderWindow* window);

    void update(sf::RenderWindow& window, sf::Event& event);
    void update(float delta);
    void render(sf::RenderWindow& window);

    void swapPaused();
private:
    typedef void (Game::*memFunc)(void);

    sf::RenderWindow* window;

    bool active;
    bool paused;


    // Testing.
    InventoryPtr myInv;
    PlayerPtr player;
	EnemyPtr myPers2;
	EnemyPtr myPers3;
    AnimatedSprite animTest;
    sf::Font MyFont;
    sf::Text text;
    PlayerController playerController;
    CameraPtr camera;
};

#endif